﻿using System.IO.Ports;
using Oxage.Common;

namespace Oxage.Models
{
	public class SerialPortModel : ModelBase
	{
		#region Constructor
		public SerialPortModel()
		{
			//Default values
			this.PortName = "COM1";
			this.BaudRate = 9600;
			this.DataBits = 8;
			this.Parity = Parity.None;
			this.StopBits = StopBits.One;
			this.Handshake = Handshake.XOnXOff;
		}
		#endregion

		#region Public properties
		public string PortName
		{
			get
			{
				return this.portName;
			}
			set
			{
				if (this.portName != value)
				{
					this.portName = value;
					OnPropertyChanged("PortName");
				}
			}
		}
		private string portName;

		public int BaudRate
		{
			get
			{
				return this.baudRate;
			}
			set
			{
				if (this.baudRate != value)
				{
					this.baudRate = value;
					OnPropertyChanged("BaudRate");
				}
			}
		}
		private int baudRate;

		public int DataBits
		{
			get
			{
				return this.dataBits;
			}
			set
			{
				if (this.dataBits != value)
				{
					this.dataBits = value;
					OnPropertyChanged("DataBits");
				}
			}
		}
		private int dataBits;

		public Parity Parity
		{
			get
			{
				return this.parity;
			}
			set
			{
				if (this.parity != value)
				{
					this.parity = value;
					OnPropertyChanged("Parity");
				}
			}
		}
		private Parity parity;

		public StopBits StopBits
		{
			get
			{
				return this.stopBits;
			}
			set
			{
				if (this.stopBits != value)
				{
					this.stopBits = value;
					OnPropertyChanged("StopBits");
				}
			}
		}
		private StopBits stopBits;

		public Handshake Handshake
		{
			get
			{
				return this.handshake;
			}
			set
			{
				if (this.handshake != value)
				{
					this.handshake = value;
					OnPropertyChanged("Handshake");
				}
			}
		}
		private Handshake handshake;
		#endregion
	}
}
